﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using AnesSystem.Models;
using System.Windows.Media;
using System.Collections.ObjectModel;
using Common;

namespace AnesSystem.Controls
{
    public class BaseDrugMethodCtrl : UserControl
    {
        #region Variables
        private ObservableCollection<BaseElementCtrl> _listCtrl = new ObservableCollection<BaseElementCtrl>();


        #endregion

        #region Constructor
        public BaseDrugMethodCtrl()
        {
            this.Loaded += BaseDrugMethodCtrl_Loaded;
        }

        public void BaseDrugMethodCtrl_Loaded(object sender, RoutedEventArgs e)
        {
           
        }

        #endregion

        #region Properties
        public ObservableCollection<BaseElementCtrl> ListCtrl
        {
            get
            {
                return _listCtrl;
            }

            set
            {
                _listCtrl = value;
            }
        }
        #endregion

        #region 依赖属性


        public Visibility DiaplyVisib
        {
            get { return (Visibility)GetValue(DiaplyVisibProperty); }
            set { SetValue(DiaplyVisibProperty, value); }
        }

        // Using a DependencyProperty as the backing store for DiaplyVisib.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty DiaplyVisibProperty =
            DependencyProperty.Register("DiaplyVisib", typeof(Visibility), typeof(BaseDrugMethodCtrl), new PropertyMetadata(Visibility.Visible));



        public string Liquid
        {
            get { return (string)GetValue(LiquidProperty); }
            set { SetValue(LiquidProperty, value); }
        }

        // Using a DependencyProperty as the backing store for Liquid.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty LiquidProperty =
            DependencyProperty.Register("Liquid", typeof(string), typeof(BaseDrugMethodCtrl), new PropertyMetadata(""));

        public PatientDrugsModel PatientDrugs
        {
            get { return (PatientDrugsModel)GetValue(PatientDrugsProperty); }
            set { SetValue(PatientDrugsProperty, value); }
        }

        // Using a DependencyProperty as the backing store for MyProperty.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty PatientDrugsProperty =
            DependencyProperty.Register("PatientDrugs", typeof(PatientDrugsModel), typeof(BaseDrugMethodCtrl), new PropertyMetadata(null));


        public List<ConfigUnitsModel> ConfigUnitsModelList
        {
            get { return (List<ConfigUnitsModel>)GetValue(ConfigUnitsModelListProperty); }
            set { SetValue(ConfigUnitsModelListProperty, value); }
        }

        // Using a DependencyProperty as the backing store for ConfigUnitsModelList.  This enables animation, styling, binding, etc...
        public static readonly DependencyProperty ConfigUnitsModelListProperty =
            DependencyProperty.Register("ConfigUnitsModelList", typeof(List<ConfigUnitsModel>), typeof(BaseDrugMethodCtrl), new PropertyMetadata(null));



        #endregion

        #region Event

        #endregion

        #region Private Methods

        #endregion

        #region Public/Protected Methods
        public virtual BaseElementCtrl CreateItem(DrugSpeedModel DrugSpeed, bool isNewAdd)
        {
            BaseElementCtrl ctrl = new BaseElementCtrl();
            return ctrl;
        }

        public virtual void Initial()
        {
            ListCtrl.Clear();
            if ((PatientDrugs.DrugSpeeds == null || PatientDrugs.DrugSpeeds.Count() < 1))
            {
                DrugSpeedModel d =  new DrugSpeedModel();
                ListCtrl.Add(CreateItem(d, true));
            }
            else
            {
                foreach (var item in PatientDrugs.DrugSpeeds)
                {
                    ListCtrl.Add(CreateItem(item, false));
                }                             
            }
        }
        #endregion

        #region EventHandlers

        #endregion

    }
}
